The ExpandString method expands a string by replacing any embedded environment variables, such as %SystemRoot%, with their corresponding values.
ExpandString(String)
An expanded string in which all environment variables have been replaced with their values.
LogFileDirectory
from the registry key HKLM\System\CurrentControlSet\Services\W3SVC\Parameters\
. The example uses the Get method to retrieve LogFileDirectory
without expanding the environment variables and then uses the ExpandString method to expand the environment variables in the string.<% Set Reg = Server.CreateObject("IISSample.Registry") LFD = Reg.Get("HKLM\System\CurrentControlSet\Services\W3SVC\Parameters\LogFileDirectory") LFDEX = Reg.ExpandString(LFD) %> LogFileDirectory = <%= LFD %><br> LogFileDirectory Expanded = <%= LFDEX %>
LogFileDirectory
is %SystemRoot%\System32\LogFiles\, the output would be:LogFileDirectory = %SystemRoot%\System32\LogFiles\ LogFileDirectory Expanded = D:\Winnt\System32\LogFiles\
Note that the second line of the preceding output could also have been generated by calling the GetExpand method.